# !/usr/bin/env python
# -*- coding:utf-8 -*-
# project name: bitu-Interface-test
# author: "Lei Yong" 
# creation time: 2019/8/1 10:14
# Email: leiyong711@163.com

from common.ReportTemplate import HTMLPortRunner


# HTML测试报告模板数据拼装
class WriteReport:

    def __init__(self):
        self.html = HTMLPortRunner()
        self.log_list = []

    def inset_log(self, log):
        """
        :param log: 新增log数据，字符串类型
        """
        self.log_list.append(log)

    def write_log(self, status, class_name, method_name, path, description, spend_time, curl):
        print(curl)
        """
        :param path:
        :param status: 用例测试状态 PASS/FAIL
        :param class_name: 用例集
        :param method_name: 请求方法
        :param description: 用例名称
        :param spend_time: 执行时间
        :param log: 用例测试日志"""
        self.html.body(status, class_name, method_name, path, description, "{:.3f} s".format(spend_time), str(self.log_list).replace(r"script", "234").replace(r'"', r'\"'), curl)
        self.log_list = []

    def empty_log(self):
        self.log_list = []

    def end_Write(self, path):
        self.html.write_file(path)
